﻿@model WaterRevenueMS.Domain.ViewModels.Authen.User.LoginModel

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <title>登录-水务管理系统</title>
    <link rel="shortcut icon" href="~/Content/image/icon.png" />
    <link href="@Url.Content("~/Content/admin/css/bootstrap.min.css")" rel="Stylesheet" />
    <link href="@Url.Content("~/Content/admin/css/bootstrap-responsive.min.css")" rel="Stylesheet" />
    <link href="@Url.Content("~/Content/admin/font-awesome/css/font-awesome.css")" rel="stylesheet" />
    <link href="@Url.Content("~/Content/admin/css/font.css")" rel="stylesheet" />
    <link href="@Url.Content("~/Content/admin/css/matrix-login.css")" rel="stylesheet" />
</head>
<body>

    <!--[if lt IE 9]>
      <script src="@Url.Content("~/Content/ieonly/html5shiv.js")" type="text/javascript"></script>
      <script src="@Url.Content("~/Content/ieonly/respond.js")" type="text/javascript"></script>
    <![endif]-->
    <div class="transbox">
        </div>
    <div id="loginbox">
       
        <div class="control-group normal_text">
            <h3>水务管理系统</h3>
        </div>
        <form id="loginform" class="form-vertical">

            <div class="control-group">
                <div class="controls">
                    <div class="main_input_box">
                        <span class="add-on bg_lg"><i class="icon-user icon-2x"></i></span>
                        @Html.TextBoxFor(m=>m.LoginName, new { @class = "span3", @placeholder = "用户名" })
                        <div></div>
                    </div>
                </div>
            </div>

            <div class="control-group">
                <div class="controls">
                    <div class="main_input_box">
                        <span class="add-on bg_ly"><i class="icon-lock icon-2x"></i></span>
                        @Html.PasswordFor(m => m.LoginPwd, new { @class = "span3", @placeholder = "密码" })
                    </div>
                </div>
            </div>

            <div class="form-actions">
                @*<span class="pull-left"><a href="#" class="flip-link btn btn-info" id="to-recover">忘记密码？</a></span>*@
                <span class="pull-right">
                    <input type="button" class="btn btn-success btn-login" id="btnlogin" value="登录" />
                </span>
            </div>
        </form>

        <form id="recoverform" class="form-vertical" action="">
            <p class="normal_text">输入您注册的email地址，我们将给您发送一封邮件说明如何重置密码。</p>

            <div class="controls">
                <div class="main_input_box">
                    <span class="add-on bg_lo"><i class="icon-envelope"></i></span>
                    <input type="text" placeholder="电子邮件" />
                </div>
            </div>

            <div class="form-actions">
                <span class="pull-left"><a href="#" class="flip-link btn btn-success" id="to-login">&laquo; 回到登录</a></span>
                <span class="pull-right"><a class="btn btn-info">发送</a></span>
            </div>
        </form>
        <div class="transbox"> </div>
    </div>

    <script src="@Url.Content("~/Content/admin/js/jquery.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Content/admin/js/bootstrap.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Content/admin/js/bootbox.min.js")" type="text/javascript"></script>
    <script type="text/javascript">

    $("#loginform").bind("keydown",function(e){
        // 兼容FF和IE和Opera    
    var theEvent = e || window.event;    
    var code = theEvent.keyCode || theEvent.which || theEvent.charCode;    
    if (code == 13) {    
        //回车执行查询
            $("#btnlogin").click();
        }    
});


        $(function () {
            //登录 发送电子邮件切换
            $('#to-recover').click(function () {

                $("#loginform").slideUp();
                $("#recoverform").fadeIn();
            });

            $('#to-login').click(function () {

                $("#recoverform").hide();
                $("#loginform").fadeIn();
            });

            //登录
            $(".btn-login").click(function () {
                var loginName = $("#LoginName").val();
                var loginPwd = $("#LoginPwd").val();
                if (trim(loginName) == "" || trim(loginPwd) == "") {
                    bootbox.alert("用户名和密码不能为空");
                } else {
                    var actionUrl = "@Url.Action("CheckLogon", "Logon")";
                    
                    var formData = $("#loginform").serialize();
                    $.ajax({
                        type: 'post',
                        url: actionUrl,
                        data: formData,
                        success: function (result) {
                            if (result.ResultType == 0) {
                                location.href = "@Url.Action("Index", "Home")";
                            } else {
                                bootbox.alert(result.Message);
                            }
                        }
                    });
                }
            });

            //删除左右两端的空格
            function trim(str) {
                return str.replace(/(^\s*)|(\s*$)/g, "");
            }
        });

    </script>
</body>
</html>

